<template>
    <BPTable ref='tableRef' align='center' row-key='id' :columns='columns' :api='page'>
        
    </BPTable>
</template>

<script lang='ts' setup>
    import { ref } from "vue";
    import { pageApi } from "@/api/merchant/IncomeLog";
    import { parseTime } from "@/utils";
import dayjs from "dayjs";

   
    const tableRef = ref()


    const buttons = ref<SearchButton[]>([])

    function page(data){
        const {date, ...params} = data
        if(date) {
            params.startTime = dayjs(date[0]).unix()
            params.endTime = dayjs(date[1]).unix()
        }
        return pageApi(params)
    }


    const columns = ref<Column[]>([
        {
            dataIndex : 'date',
            title : '日期',
            inSearch : true,
            type : 'rangePicker',
            customRender({text}){
                return parseTime(text, '{y}-{m}-{d}')
            }
        },

        {
            dataIndex : 'amount',
            title : '收入(元)',
        },

        {
            dataIndex : 'kwh',
            title : '耗电量(度)',
        },

        {
            dataIndex : 'time',
            title : '充电时长'
        },

        
    ])
</script>